def solution(S: str) -> int:
    # PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    # write code here
    from collections import Counter
    char_count = Counter(S)

    res = 0
    for c in char_count:
        res += char_count[c] // 2

    return res


if __name__ == '__main__':
    print(solution(S="abab") == 2)
    print(solution(S="aaaa") == 2)
    print(solution(S="abcabc") == 3)